package com.yc.class_attendance.utils;

import com.yc.class_attendance.entity.AttendanceResutl;
import com.yc.class_attendance.entity.Record;

import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date;

public class ComparatorDate implements Comparator {
	 public static final String TAG = "ComparatorDate";


	    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	    public int compare(Object obj1, Object obj2) {
			AttendanceResutl.CourseBean.ListBean t1 = (AttendanceResutl.CourseBean.ListBean) obj1;
			AttendanceResutl.CourseBean.ListBean t2 = (AttendanceResutl.CourseBean.ListBean) obj2;
	        Date d1, d2;
	        try {
	            d1 = format.parse(t1.getmCurrenTime());
	            d2 = format.parse(t2.getmCurrenTime());
	        } catch (Exception e) {
	            //  解析出错，则不进行排序
	         //   MyLog.e(TAG, "ComparatorDate--compare--SimpleDateFormat.parse--error");
	            return 0;
	        }
	        if (d1.before(d2)) {
	            return 1;
	        } else {
	            return -1;
	        }
	    }
}
